﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SzCourt.Logic.BLL;
using KMFrame.Core;

namespace SzCourt.WebSite.shenwu
{
    public partial class gglist : System.Web.UI.Page
    {
        public int PageIndex = 1;
        public int PageSize = 10;
        public int TotalPage = 1;
        public string Keyword = string.Empty;
        private string Tag = string.Empty;
        private string mTitle = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                getList();
            }
        }

        private void getList()
        {
            this.PageIndex = string.IsNullOrEmpty(Request.QueryString["PageIndex"]) ? 1 : Convert.ToInt32(Request.QueryString["PageIndex"]);
            this.Keyword = string.IsNullOrEmpty(Request.QueryString["keyword"]) ? "" : Request.QueryString["keyword"];
            this.Tag = string.IsNullOrEmpty(Request.QueryString["tag"]) ? "" : Request.QueryString["tag"];
            this.txtKeyword.Value = this.Keyword;
            this.hdnTag.Value = this.Tag;

            KeyWordCondition param = new KeyWordCondition();
            param.PageIndex = this.PageIndex;
            param.PageSize = this.PageSize;

            //根据传参取不同的文章
            if (this.Tag.Length > 0)
            {
                switch (this.Tag)
                {
                    case "SDGG":
                        this.mTitle = "送达公告";
                        param.Type = ArticlesTypes.SDGG;
                        break;
                    case "PGJGMD":
                        this.mTitle = "评估拍卖机构名单";
                        param.Type = ArticlesTypes.PGJGMD;
                        break;
                    case "ZJJGGG":
                        this.mTitle = "中介机构公告";
                        param.Type = ArticlesTypes.ZJJGGG;
                        break;
                    case "DCLXZWLGG":
                        this.mTitle = "督促履行债务令公告";
                        param.Type = ArticlesTypes.DCLXZWLGG;
                        break;
                    case "ZFL":
                        this.mTitle = "支付令";
                        param.Type = ArticlesTypes.ZFL;
                        break;
                    case "PCGG":
                        this.mTitle = "破产公告";
                        param.Type = ArticlesTypes.PCGG;
                        break;
                    case "QTGG":
                        this.mTitle = "其他公告";
                        param.Type = ArticlesTypes.QTGG;
                        break;
                    case "ZXFLGZ":
                        this.mTitle = "执行法律法规规章";
                        param.Type = ArticlesTypes.ZXFLGZ;
                        break;
                    case "ZXGZDT":
                        this.mTitle = "执行工作动态";
                        param.Type = ArticlesTypes.ZXGZDT;
                        break;
                    case "ZXGS":
                        this.mTitle = "执行故事";
                        param.Type = ArticlesTypes.ZXGS;
                        break;
                    case "ZYBG":
                        this.mTitle = "中院报告";
                        param.Type = ArticlesTypes.ZYBG;
                        break;
                    default:
                        this.mTitle = "送达公告";
                        param.Type = ArticlesTypes.SDGG;
                        break;
                }
            }
            
            //有搜索关键字就赋值
            if (this.Keyword.Length > 0)
            {
                param.KeyWord = this.Keyword;
            }

            Articles art = new Articles();
            PageResult result = (PageResult)art.GetArticlesPage(param);

            if (result != null)
            {
                this.rptDataList.DataSource = result.ResultList;
                this.rptDataList.DataBind();

                this.pager1.RecordCount = result.TotalCount; //实际的库存数量
                this.pager1.TotalPage = result.PageCount;
                this.pager1.PageIndex = this.PageIndex;
                this.pager1.PageSize = this.PageSize;
                this.pager1.LinkUrl = "/shenwu/gglist.aspx?PageIndex=" + this.PageIndex.ToString() + "&tag=" + this.Tag+"&keyword="+this.Keyword ;
                this.pager1.IsResult = false;

                
            }
            SetPageInfo();
        }

        /// <summary>
        /// 写页面title,keyword,description
        /// </summary>
        /// <param name="mWord"></param>
        private void SetPageInfo()
        {
            this.TabName.InnerHtml = this.mTitle;
            Page.Title = string.Format("{0} 审务公开  - 深圳市中级人民法院", this.mTitle);

            
        }

    }
}